﻿<Window x:Class="Sample.StackOverflow.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:local="clr-namespace:Sample.StackOverflow"
        Background="{StaticResource standardWindowBrush}"
        Icon="{StaticResource applicationIcon}"
        Title="StackOverflow Users" Height="560" Width="480" FontSize="14">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="60" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <DockPanel
            Grid.Row="0">
            <Button
                DockPanel.Dock="Right"
                Margin="0,10,10,10"
                Width="64"
                Command="{Binding SearchCommand}">Search</Button>
            <TextBox
                Margin="10,5" VerticalAlignment="Center"
                FontSize="26"
                Text="{Binding SearchFilter}" />
        </DockPanel>
        <ListBox
            Grid.Row="1"
            ItemsSource="{Binding SearchResults}"
            HorizontalContentAlignment="Stretch"
            Background="Transparent">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border
                        BorderBrush="DarkGray"
                        BorderThickness="1"
                        CornerRadius="3">
                        <Grid Height="40">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="60" />
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>

                            <TextBlock
                                Grid.Column="0"
                                VerticalAlignment="Center"
                                Margin="4,0,0,0"
                                Text="{Binding display_name}" />
                            <TextBlock
                                Grid.Column="1"
                                VerticalAlignment="Center"
                                Text="{Binding reputation}" />

                            <local:BadgesUserControl
                                Grid.Column="2"
                                DataContext="{Binding badge_counts}" />

                        </Grid>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <ProgressBar
            Grid.Row="1"
            Height="40" Width="180"
            IsIndeterminate="True"
            Visibility="{Binding IsBusy, Converter={StaticResource booleanVisibilityConverter}}" />
    </Grid>
</Window>
